package com.sdkx.app.adapter;

import android.content.Context;
import android.graphics.Color;
import android.media.Image;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.sdkx.app.R;
import com.sdkx.app.entity.CustomWayPoint;

import java.util.List;


public class WaypointThreeMenuAdapter extends BaseAdapter {
    private Context context;
    private List<CustomWayPoint> list;

    public WaypointThreeMenuAdapter(Context context, List<CustomWayPoint> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        final MyViewHolder vh;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.grid_item, null);
            vh = new MyViewHolder(convertView);
            convertView.setTag(vh);
        } else {
            vh = (MyViewHolder) convertView.getTag();
        }
            vh.text.setText(list.get(position).getName());
            vh.iv_icon.setVisibility(View.GONE);

        return convertView;
    }


    public static class MyViewHolder {
        public TextView text;
        public View itemView;
        public ImageView iv_icon;
        public MyViewHolder(View itemView) {
            this.itemView = itemView;
            text = (TextView) itemView.findViewById(R.id.textView);
            iv_icon = (ImageView) itemView.findViewById(R.id.iv_icon);
        }
    }

}
